package com.canbot.u05.adapter;


import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.view.ViewGroup;

import com.canbot.u05.fragment.CompereFragment;
import com.canbot.u05.utils.Logger;

import java.util.List;

/**
 * Created by XH on 2017/3/3.
 */

public class CompereVpAdapter extends FragmentPagerAdapter {

        private FragmentManager fm;

        List<CompereFragment> fragmentList;

        public CompereVpAdapter(FragmentManager fm, List<CompereFragment> fragmentList) {
                super(fm);
                this.fm = fm;
                this.fragmentList = fragmentList;
        }

        public CompereVpAdapter(FragmentManager fm) {
                super(fm);

        }

        @Override
        public Fragment getItem(int i) {
                Logger.d("compere", "fragment 序号" + i);
                return fragmentList.get(i);
        }

        @Override
        public int getCount() {
                Logger.d("compere", "fragments " + fragmentList.size());
//        return fragmentList.size();
                return fragmentList.size();
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
                Fragment fragment = (Fragment) super.instantiateItem(container, position);
                return fragment;
        }

        @Override
        public int getItemPosition(Object object) {
                return PagerAdapter.POSITION_NONE;
        }
}
